package hw2.cs236369.parsing;

import hw2.cs236369.interfaces.IAuthor;

/**
 * Author Class.
 * 
 * @author gil
 * 
 */
public class Author implements IAuthor {
	private String	_name;

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Object#hashCode()
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((_name == null) ? 0 : _name.hashCode());
		return result;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}
		if (obj == null) {
			return false;
		}
		if (!(obj instanceof Author)) {
			return false;
		}
		Author other = (Author)obj;
		if (_name == null) {
			if (other._name != null) {
				return false;
			}
		} else if (!_name.equals(other._name)) {
			return false;
		}
		return true;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return _name;
	}

	/**
	 * Creates a new author.
	 * 
	 * @param name The author's name
	 */
	public Author(String name) {
		_name = name;
	}

	@Override
	public String getName() {
		return _name;
	}

}
